home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 65.zip / BS1 part 65 / Math Visin v2.1 disk 2.adf / Arexx.CLI / Zoom.rexx < prev   
OS/2 REXX Batch file  |  1992-02-14  |  5KB  |  133 lines

  1. /* ZOOM.REXX, an ARexx program for MathVision, 3-Sep-89 dh
  2.  
  3.   This generic Arexx program will allow you to create a series of zoomed
  4. pictures in contour plot mode.  It is assumed that you have already entered
  5. the appropriate functions, colors and setting in MathVision.
  6. It takes into account the fact that as you zoom in closer, you must use
  7. smaller increments.
  8.  
  9.   To use this program, you must edit this file, and put in the appropriate
  10. values in the User Settings section which follows. 
  11.  
  12.   The 'BaseFilename' is the basic name which will be used for all the pictures.
  13. For example, if you put "PLOTS:PIC", the files will be named "PLOTS:PIC0000",
  14. "PLOTS:PIC0001", "PLOTS:PIC0002", and so on.  The number of the picture is 
  15. appended to the basic file name.
  16.  
  17.   'Pictures' is how many frames you want in this zoom.  A higher setting
  18. here will give you smoother animation.  The pictures will be numbered starting
  19. at 0 and going up to Pictures-1.
  20.  
  21.   'StartPicture' is useful if your plotting has to be restarted because of
  22. some interrupt, like a Drastic Power Failure or Real Work.  Just plug in the
  23. number of the next picture to plot, and it will start right there.  Normally
  24. this value is 0.  This lets you work on your computer during the day, and
  25. resume the plotting during the night.
  26.  
  27.   You must give the starting and ending coordinates of your zoom.  These 
  28. are given in the variables xmin_start, xmin_end, and etc. 
  29.  
  30. */
  31.  
  32. /*============================== User Settings =============================*/
  33. NUMERIC DIGITS 15
  34. Pictures = 100            /* Number of pictures to plot */
  35. StartPicture = 0        /* Picture to start plotting with */
  36. BaseFilename = "Mandelbrot_Zoom:Pic"    /* Basic pathname for pictures */
  37.  
  38. xmin_start = -2            /* coordinates of starting (big) picture */
  39. xmax_start =  2    
  40. ymin_start = -1.5
  41. ymax_start =  1.5
  42.  
  43. xmin_end   = -0.7372        /* coordinates of ending (small) picture */
  44. xmax_end   = -0.7367
  45. ymin_end   =  0.2012
  46. ymax_end   =  0.2016
  47.  
  48. /*==========================================================================*/
  49. /* THEORY OF OPERATION:
  50.  
  51.   Zooming was not a simple as I first imagined.  Suppose you have a frame
  52. which is 10 centimeters square, and you wish to zoom in on a picture that
  53. is 1 centimeter square, and you wish to zoom in by 1-centimeter increments.
  54. The first zoom, from 10 to 9, gives you a zoom factor of 10/9, or 111%.
  55. But as you get closer, the zoom factor increases.  From 9 to 8, the zoom
  56. factor is 9/8, or 112%, and from 2 to 1 the zoom factor is 2/1, or 200%.
  57. As you get closer, you zoom faster, which is not the effect you want.
  58.  
  59.   One way to get around this problem is to use logarithms.  I won't bore
  60. you with the details, but we first convert our numbers to logarithms so
  61. we can make a linear zoom, and then convert back to the numbers we want.
  62. I consider the x and y dimensions separately, in case the aspect ratio
  63. changes.
  64.  
  65.   As for the implementation, I wrote two little functions at the end of
  66. the program which kick MathVision to do some logarithmic stuff.  This is
  67. necessary because I could not do the logarithms in ARexx, but MathVision has 
  68. no problem with it.
  69. */
  70.    
  71. ADDRESS "MathVision"
  72. OPTIONS RESULTS            /* We need answers */
  73. OPTIONS FAILAT 1        /* everything is fatal */
  74. SIGNAL ON ERROR            /* if error, goto ERROR: */
  75.  
  76. xstart_span     = xmax_start - xmin_start    /* compute handy variables */
  77. ystart_span     = ymax_start - ymin_start
  78. xend_span       = xmax_end   - xmin_end
  79. yend_span       = ymax_end   - ymin_end
  80. log_xstart_span = log(xstart_span)
  81. log_ystart_span = log(ystart_span)
  82. log_xend_span   = log(xend_span  )
  83. log_yend_span   = log(yend_span  )
  84.  
  85.  
  86.  
  87. DO PictureNumber = StartPicture TO Pictures-1        /* for each picture...*/
  88.  
  89.   Filename = BaseFilename||Right(PictureNumber,4,"0")    /* status report */
  90.   SAY "Plotting:"Filename
  91.  
  92.   mult = (PictureNumber) / (Pictures-1)        /* 0..1 */
  93.  
  94.   t = log_xstart_span - ((log_xstart_span - log_xend_span) * mult)
  95.   xmult = (exp(t)-xend_span)/(xstart_span - xend_span)
  96.  
  97.   t = log_ystart_span - ((log_ystart_span - log_yend_span) * mult)
  98.   ymult = (exp(t)-yend_span)/(ystart_span - yend_span)
  99.  
  100.                 /* plug in the new values */
  101.   Xmin xmin_end - (xmin_end - xmin_start)*xmult
  102.   Xmax xmax_end - (xmax_end - xmax_start)*xmult
  103.   Ymin ymin_end - (ymin_end - ymin_start)*ymult
  104.   Ymax ymax_end - (ymax_end - ymax_start)*ymult
  105.  
  106.   PlotContour             /* do the appropriate plot */
  107.  
  108.   Pathname Filename        /* set the name for this file */
  109.   SavePicture             /* save it to disk */
  110.  
  111.   Get StopSign
  112.   IF RESULT = "T" THEN BREAK
  113. END /* do */
  114. EXIT
  115.   
  116. /*------------------------------- functions ------------------------------- */
  117.  
  118. log:            /* log base 10 */
  119.   arg n
  120.   Get Eval "log10("n")"    /* kick MathVision to give us the answer to log10(n) */
  121.   return(result)
  122.  
  123. exp:            /* exponent base 10 */
  124.   arg n
  125.   Get Eval "10^"n
  126.   return(result)
  127.  
  128. ERROR:            /* Error Diagnostic for return codes */
  129.  
  130.   Get Diagnosis RC
  131.   SAY RESULT" on line "SIGL
  132.   EXIT
  133.